package org.kernely.ui.mvp;

import java.util.HashMap;

/**
 * Contains an association between views and presenters.
 */
public class KernelyViewPresenterManager
extends HashMap<Class<? extends IKernelyView>,
				Class<? extends IKernelyPresenter>>{
	
	/**
	 * Get a new instance of the presenter associated to the view.
	 * @param view The IKernelyView class associated to the presenter.
	 * @return an instance of the presenter associated to the view.
	 */
	public final IKernelyPresenter getPresenterInstance(Class<? extends IKernelyView> viewClass){
		try {
			return this.get(viewClass).newInstance();
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		}
		return null;
	}
}
